import torch.nn as nn
from abc import abstractmethod


class BaseEncoder(nn.Module):

    @abstractmethod
    def forward(self, src, lengths=None):
        """
        Input:
            src : [batch, max_src_len, n_features]
            lengths : [batch, ]
        Output:
            final_state : final_encoder_state, 用于初始化Decoder的状态
            memory_bank : [batch, max_src_len, hidden] 用于计算注意力，于Input一一对应
            lengths : [batch, ]
        """
        raise NotImplementedError

    @classmethod
    def from_opt(cls, opt, embedding=None):
        raise NotImplementedError
